var bodyWidth = $(document.body).width();
var rollIdx = 0;
$(document).ready(function(){
	// 按实际宽度重新设置元素宽度
	var w300 = parseInt(0.967*bodyWidth,10);//0.943*bodyWidth;
	var w4 = parseInt(0.0129*bodyWidth,10);
	var w14 = parseInt(0.0451*bodyWidth,10);//0.044*bodyWidth;
	var w290 = parseInt(0.935*bodyWidth,10);//0.911
	var w160 = parseInt(0.516*bodyWidth,10);//503
	var w10 = parseInt(0.0322*bodyWidth,10);//0314
	var w870 = parseInt(2.806*bodyWidth,10);//2.735
	var w190 = parseInt(0.612*bodyWidth,10);// 597
	var w140 = parseInt(0.451*bodyWidth,10);// 361
	var w12 = parseInt(0.038*bodyWidth,10);// 037
	var w90 = parseInt(0.29*bodyWidth,10);//283
	var w48 = parseInt(0.154*bodyWidth,10);
	var w8 = parseInt(0.025*bodyWidth,10);;
	var w23 = parseInt(0.074*bodyWidth,10);
	var w25 = parseInt(0.08*bodyWidth,10);;
	var w12 = parseInt(0.038*bodyWidth,10);
	var w32 = parseInt(0.103*bodyWidth,10);
	var w40 = parseInt(0.129*bodyWidth,10);
	var w50 = parseInt(0.161*bodyWidth,10);
	var w20 = parseInt(0.064*bodyWidth,10);
	var w16 = parseInt(0.051*bodyWidth,10);
	var w18 = parseInt(0.058*bodyWidth,10);
	var w24 = parseInt(0.077*bodyWidth,10);
	
	// 主框
	$(".wbox").css("width",w300+"px");// 300
	$(".wbox").css("padding-left","0px");// 4
	$(".wbox").css("padding-right",w10+"px");// 14
	// 图片固定框
	$(".toppictures").css("width",w290+"px");// 290
	$(".toppictures").css("height",w160+"px");// 160
	$(".toppictures").css("margin-top",w14+"px");// 14
	$(".toppictures").css("margin-right","0px");// 0
	$(".toppictures").css("margin-bottom",w14+"px");// 14
	$(".toppictures").css("margin-left",w10+"px");// 10
	// 滚动移动框
	$(".picturesbox").css("width",w870+"px");// 870
	$(".picturesbox").find("img").css("width",w290+"px");// 290
	// 滚珠定位
	$(".rollitems").css("left",w190+"px");
	$(".rollitems").css("top",w140+"px");
	$(".rollitems").find("a").css({"margin-right":w12+"px","font-size":w14+"px"});
	// 子项边距
	$(".witem").css("margin-left",w10+"px");
	$(".witem").css("margin-bottom",w10+"px");
	// 大小类型设置
	$(".wsize1").css({"width":w90+"px","height":w90+"px"});
	$(".wsize2").css({"width":w190+"px","height":w90+"px"});
	$(".wsize3").css({"width":w290+"px","height":w90+"px"});
	$(".wsize4").css({"width":w90+"px","height":(w190-2)+"px"});
	$(".wsize5").css({"width":w190+"px","height":(w190-2)+"px"});
	$(".wsize6").css({"width":w290+"px","height":(w190-2)+"px"});
	$(".witem").find("img").css({"width":w48+"px","height":w48+"px"});
	
	$(".img1").css({"margin-top":w8+"px"});
	$(".img2").css({"float":"left","margin-top":w23+"px","margin-right":w4+"px","margin-bottom":"0px","margin-left":w25+"px"});
	$(".img3").css({"float":"left","margin-top":w23+"px","margin-right":w32+"px","margin-bottom":"0px","margin-left":w40+"px"});
	$(".img4").css({"margin-top":w23+"px"});
	$(".img5").css({"margin-top":w50+"px"});
	$(".img6").css({"margin-top":w50+"px"});
	
	$(".font1").css({"font-size":w16+"px","margin-top":w4+"px"});
	$(".font2").css({"font-size":w16+"px","float":"left","line-height":w90+"px"});
	$(".font3").css({"font-size":w24+"px","float":"left","line-height":w90+"px"});
	$(".font4").css({"font-size":w16+"px","width":w16+"px","line-height":w18+"px","margin-top":w4+"px","margin-right":"auto","margin-bottom":"0px","margin-left":"auto"});
	$(".font5").css({"font-size":w20+"px","margin-top":w8+"px"});
	$(".font6").css({"font-size":w24+"px","margin-top":w8+"px"});
	// 载入图片
	for(i=0;i<pictures.length;i++){
		$(".picturesbox").find("img").eq(i).prop("src",pictures[i].url);
		$(".picturesbox").find("img").eq(i).show();
		$(".rollitems").find("a").eq(i).show();
	}
	// 滚动控制
	if(1<pictures.length){
		$(".rollitems").show();
		$(".rollitems").find("a").eq(0).text("●");
		var rolltask =setInterval(function(){
			$(".rollitems").find("a").text("○");
			if(0==rollIdx){
				$(".picturesbox").animate({"left":"-"+w290+"px"},"500");
				$(".rollitems").find("a").eq(1).text("●");
				rollIdx = 1;
			}else if(1==rollIdx){//(("-"+w290+"px")==$(".picturesbox").css("left")){
				if(2==pictures.length){
					$(".picturesbox").animate({"left":"0px"},"500");
					$(".rollitems").find("a").eq(0).text("●");
					rollIdx = 0;
				}else{
					$(".picturesbox").animate({"left":"-"+(2*w290)+"px"},"500");
					$(".rollitems").find("a").eq(2).text("●");
					rollIdx = 2;
				}
			}else if(2==rollIdx){
				$(".picturesbox").animate({"left":"0px"},"500");
				$(".rollitems").find("a").eq(0).text("●");
				rollIdx = 0;
			}
		},4000);
	}
	$(".itemsbox").show();
});